define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
    var Controller = {
        index: function () {
            //
            // 初始化表格参数配置
            Table.api.init();
            this.table.first();
            this.table.second();
            this.table.third();
        },
        table:{
            first: function (){
               // console.log(33);
                console.log(11);
                var table = $("#table");

                // 在普通搜索渲染后
                table.on('post-common-search.bs.table', function (event, table) {
                    var form = $("form", table.$commonsearch);
                    // 进行隐藏
                    $('.fixed-table-toolbar').attr('class','commonsearch-table hidden')
                    // 重新渲染
                    Form.events.selectpage(form);
                });



                // 初始化表格
                table.bootstrapTable({
                    url: 'agent/customsearchqhz/index',
                    pk: 'id',
                    sortName: 'id',
                    searchFormVisible: true,
                    searchFormTemplate: 'customformtpl',
                    columns: [
                        [
                            {field: 'itemsName', title: __('Category name'), operate: false},
                            {field: 'itemsValue', title: __('Category value'), operate: false},
                        ]
                    ]
                });

                // 为表格绑定事件
                Table.api.bindevent(table);
            },
            second: function (){
                console.log(22);
                var table2 = $("#table2");

                // 在普通搜索渲染后
                table2.on('post-common-search.bs.table', function (event, table) {
                    var form = $("form", table.$commonsearch);
                    // 进行隐藏
                    $('.fixed-table-toolbar').attr('class','commonsearch-table hidden')
                    // 重新渲染
                    Form.events.selectpage(form);
                });



                // 初始化表格
                table2.bootstrapTable({
                    url: 'agent/customsearchqhz/index2',
                    pk: 'id',
                    sortName: 'id',
                    searchFormVisible: true,
                    searchFormTemplate: 'customformtpl',
                    columns: [
                        [
                            {field: 'itemsName', title: __('Category name'), operate: false},
                            {field: 'itemsValue', title: __('Category value'), operate: false},
                        ]
                    ]
                });

                // 为表格绑定事件
                Table.api.bindevent(table2);
            },

            third: function (){
                console.log(33);
                var table3 = $("#table3");

                // 在普通搜索渲染后
                table3.on('post-common-search.bs.table', function (event, table) {
                    var form = $("form", table.$commonsearch);
                    // 进行隐藏
                    $('.fixed-table-toolbar').attr('class','commonsearch-table hidden')
                    // 重新渲染
                    Form.events.selectpage(form);
                });



                // 初始化表格
                table3.bootstrapTable({
                    url: 'agent/customsearchqhz/index3',
                    pk: 'id',
                    sortName: 'id',
                    searchFormVisible: true,
                    searchFormTemplate: 'customformtpl',
                    columns: [
                        [
                            {field: 'itemsName', title: __('Category name'), operate: false},
                            {field: 'itemsValue', title: __('Category value'), operate: false},
                        ]
                    ]
                });

                // 为表格绑定事件
                Table.api.bindevent(table3);
            }


        },

        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});
